package edu.hqu.deepspace.controller;

import edu.hqu.deepspace.pojo.Admin;
import edu.hqu.deepspace.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * @author Lenovo
 */
@Controller
@RequestMapping("/Admin")
public class AdminController {
    @Autowired
    @Qualifier("AdminServiceImpl")
    private AdminService adminService;


    @RequestMapping("/jumplogin")
    public String jumpLogin() throws Exception {
        return "Login";
    }
//跳转登录界面

    @RequestMapping("/login")
    String login(Admin admin, HttpSession session){
        Admin admin1;
        try{
            admin1 = adminService.login(admin);
            session.setAttribute("msg",admin1.getName());
        }catch (Exception e){
            return "DefaultLogin";
        }
        return "Authentication";
    }
//登录界面及其相关验证



    @RequestMapping("/Menu")
    String loginSucess(){
        return "Menu";
    }
//跳转管理菜单总界面

    @RequestMapping("/logout")
    public String logout(HttpSession session) throws Exception {
        // session 过期
        session.invalidate();
        return "Login";
    }
//退出登录

}
